<?php //debugvar($topCategoryId, 'topCategoryId'); ?> 
<?php $arCategories = Category::getRealList(0); ?>                            
                            <ul>
                                <?php if( !empty($arCategories) ): ?>
                                    <?php $i = 0; ?>
                                    <?php foreach( $arCategories as $category ): ?>
                                    <?php //debugvar($i,'i'); ?>
                                        <?php if( $i >= 7 ): ?>
                                            <?php break; ?>
                                        <?php  endif; ?>
                                        <?php $i++; ?>
            <?php //debugvar($i, 'i'); ?>
            <?php //debugvar($category->getId(), 'category->getId()'); ?>

        <?php $li_class = '' ?>
        <?php if(isset($topCategoryId)): ?>                                        
            <?php if($category->getId() == $topCategoryId): ?>
                <?php $li_class = 'activetop_' ?>
            <?php endif; ?>
        <?php endif; ?>

        <?php if($i == 1): ?>
            <?php $li_class .= 'first'; ?>
        <?php endif; ?>

        <?php if($i == 7): ?>
            <?php $li_class .= 'last'; ?>
        <?php endif; ?>

        <?php if($i != 1 and $i != 7): ?>
            <?php $li_class .= 'middle'; ?>
        <?php endif; ?>

<?php //debugvar($li_class, 'li_class'); ?>

                <li id="menu_top_<?php echo ($i+1) ?>" class="<?php echo $li_class ?>"><table width="100%" cellspacing="0" cellpadding="0" height="43"><tr><td align="center" valign="middle">
                      <?php echo link_to(
                                     $category->getName()
                                     , 'product/topcategory?id='.$category->getId()
                                        );
                                       ?>
                 </td></tr></table></li>
                           <?php endforeach; ?>
                       <?php else: ?>
                           No categories
                       <?php endif; ?>
                   </ul>
